/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.service;

import br.com.foxline.model.Reserve;
import java.rmi.RemoteException;
import java.util.Calendar;
import java.util.Date;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.TimerService;
import javax.ejb.*;

/**
 *
 * @author luciano
 */
@Stateless
public class ManagerReservaBean {

    @Resource
    private TimerService service;
    @EJB
    private ReserveService reserveService;
    
    public void startTimer(Reserve  reserve) {
        Date d = new Date(reserve.getExpiresAt().getTime() + 10000);
        Timer timer = service.createTimer(d, "Expira Reserva");
    }
    
    @Timeout
    public void handleTimeout(Timer timer) {
        reserveService.expireReserve();
    }
    
}
